<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\library\services\lib\tencentCloud\Cos;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class TestController extends Controller
{
    public function upfile(Request $request)
    {
        if ($request->hasFile('file')){
            $file = $request->file('file');
            //原文件名
            $originalName = $file->getClientOriginalName();
            //扩展名
            $ext = $file->getClientOriginalExtension();
            //MimeType
            $type = $file->getClientMimeType();
            //临时绝对路径
            $realPath = $file->getRealPath();
            $filename = 'fangOutRent'.'/'.uniqid() . '.' . $ext;
            $cos = new Cos();
            $res = $cos->uoloadFile($filename, $realPath);
            return $this->res($res);
        }
        return $this->fail('无图片上传');
    }
}
